<template>
  <view>
    <view class="loadingClass">拼命加载中... </view>
  </view>
</template>

<script setup>
import { useMemberStore } from "@/stores/modules/member";
import { get_user_info } from "./index";
import { baseURL } from "@/utils";
const memberStore = useMemberStore();
const scanLogin = () => {
  dd.getAuthCode({
    success: (res) => {
      dd.httpRequest({
        headers: {
          "Content-Type": "application/json",
        },
        url: `${baseURL}/zgjmAPI/dingtalk/login?code=${res.authCode}`,
        method: "get",
        dataType: "json",
        timeout: 30000,
        success: async (result) => {
          const res = result.data;
          if (res?.code == 200) {
            memberStore.token = res.token;
            memberStore.userId = res.userInfo.id;
            memberStore.userName = res.userInfo.username;
            memberStore.deptMap = res.userInfo.roles;
            memberStore.userInfo = res.userInfo;
            uni.switchTab({
              url: "/pages/index/index",
            });
          }
        },
      });
    },
  });
};
onShow(() => {
  scanLogin();
});
</script>

<style lang="scss" scoped>
</style>
